//
//  YDPositionInPositonCell.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2017/11/9.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "YDPositionInPositonCell.h"
#import "YDPositionModel.h"

@interface YDPositionInPositonCell()
//股票名称
@property (nonatomic , weak) UILabel *stockName;
//股票代码
@property (nonatomic , weak) UILabel *stockCode;
//当前状态
@property (nonatomic , weak) UIImageView *currentStatus;
//时间图示
@property (nonatomic , weak) UIImageView *timeImage;
//年月日
@property (nonatomic , weak) UILabel *year;
//时分秒
@property (nonatomic , weak) UILabel *hour;
//订单号
@property (nonatomic , weak) UILabel *orderLabel;
//订单number
@property (nonatomic , weak) UILabel *orderNumber;



//点买本金
@property (nonatomic , weak) UILabel *principal;
//点买数值
@property (nonatomic , weak) UILabel *principalNumber;
//可用
@property (nonatomic , weak) UILabel *available;
//可用数值
@property (nonatomic , weak) UILabel *availableNumber;
//持仓类型
@property (nonatomic , weak) UILabel *positionType;
@property (nonatomic , weak) UILabel *positionTypeNumber;



//盈亏
@property (nonatomic , weak) UILabel *profitLoss;
//盈亏数值
@property (nonatomic , weak) UILabel *profitLossNumber;
//止损
@property (nonatomic , weak) UILabel *stop;
//止损数值
@property (nonatomic , weak) UILabel *stopNumber;
//杠杆
@property (nonatomic , weak) UILabel *gangganLabel;
@property (nonatomic , weak) UILabel *gangganNumber;


//买入价
@property (nonatomic , weak) UILabel *bidPrice;
//买入价数值
@property (nonatomic , weak) UILabel *bidPriceNumber;
//当前价
@property (nonatomic , weak) UILabel *currentPrice;
//当前价数值
@property (nonatomic , weak) UILabel *currentPriceNumber;
//是否递延
@property (nonatomic , weak) UILabel *derLabel;
@property (nonatomic , weak) UILabel *derLabelNumber;

//卖出按钮
@property (nonatomic , weak) SYNoHeightedButton *saleButton;
@end

@implementation YDPositionInPositonCell

-(void)setModel:(YDPositionModel *)model
{
    _model = model;
    //股票代码及名称
    self.stockName.text = model.stockName;
    self.stockCode.text = model.stockCode;
    //时间
    self.year.text = model.buyYearStr;
    self.hour.text = model.buyHourStr;
    //状态
    self.currentStatus.image = [UIImage imageNamed:model.stateString];
    
    //交易单号
    self.orderNumber.text = model.tradeNo;
    
    
    //卖出按钮状态
    self.saleButton.enabled = model.isCanSale;

    //盈亏
    if ([model.pzProfitOrLoss isEqualToString:@"--"]) {
        self.profitLossNumber.textColor = NumberColor(178, 176, 179);
    }else if ([model.pzProfitOrLoss floatValue] > 0){
        self.profitLossNumber.textColor = [UIColor colorWithHexString:Orange];
    }else{
        self.profitLossNumber.textColor = NumberColor(71, 194, 51);
    }
    self.profitLossNumber.text = model.pzProfitOrLoss;


    //可用股票
    self.availableNumber.text = model.pzNumberOfStrand;
    //买入价格
    self.bidPriceNumber.text = model.pzBuyingPrice;
    //止损数
    self.stopNumber.text = model.lossNumber;
    //点买本金
    self.principalNumber.text = model.pzReserveFund;
    //当前价
    self.currentPriceNumber.text = model.pzCurrentPrice;
    
    
    //是否递延
    if (model.deferred) {
        self.derLabelNumber.text = @"是";
    }else{
        self.derLabelNumber.text = @"否";
    }
    
    //持仓类型
    if (model.cycle) {
        self.self.positionTypeNumber.text = [NSString stringWithFormat:@"T+%ld",model.cycle.integerValue];
    }
    //杠杆
    if (model.lossMultiple) {
        self.gangganNumber.text = [NSString stringWithFormat:@"%ld倍",model.lossMultiple.integerValue] ;
    }
    
    //是否停牌
    if ([model.stockStatus integerValue] == 1) {//正常
        self.currentPriceNumber.textColor = [UIColor colorWithHexString:paleRed];
    }else{
        self.currentPriceNumber.text = @"停牌";
        self.currentPriceNumber.textColor = [UIColor colorWithHexString:dark];
    }

}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *positionInPositonCell = @"YDPositionInPositonCell";
    YDPositionInPositonCell *cell = [tableView dequeueReusableCellWithIdentifier:positionInPositonCell];
    if (cell == nil) {
        cell = [[YDPositionInPositonCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:positionInPositonCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor whiteColor];
        [self addDashLine];
        [self stockName];//股票名称
        [self stockCode];//股票代码
        [self currentStatus];//当前状态
        [self timeImage];//时间图示
        [self year];//年月日
        [self hour];//时分秒
        
    
        //订单号
        [self orderLabel];
        [self orderNumber];
        
        [self principal];//点买本金
        [self principalNumber];//点买数值
        [self available];//可用
        [self availableNumber];//可用数值
        [self positionType];//持仓类型
        [self positionTypeNumber];//


        [self profitLoss];//盈亏
        [self profitLossNumber];//盈亏数值
        [self stop];//止损
        [self stopNumber];//止损数值
        [self gangganLabel];//杠杆
        [self gangganNumber];
        

        [self bidPrice];//买入价
        [self bidPriceNumber];//买入价数值
        [self currentPrice];//当前价
        [self currentPriceNumber];//当前价数值
        [self derLabel];//是否递延
        [self derLabelNumber];
        
        [self saleButton];//卖出按钮
        
    }
    return self;
}
/****股票名称*****/
-(UILabel *)stockName
{
    if (_stockName == nil) {
        UILabel *stockName = [[UILabel alloc] init];
        [self.contentView addSubview:stockName];
        stockName.textColor = [UIColor colorWithHexString:dark];
        stockName.font = [UIFont systemFontOfSize:font18ScreenWRate * LKScreenW];
        stockName.textAlignment = NSTextAlignmentLeft;
        stockName.text = @"平安银行";
        [stockName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(10));
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(16));
            }else{
                make.top.equalTo(self).offset(rate750(16));
            }
        }];
        _stockName = stockName;
    }
    return _stockName;
}
/****股票代码*****/
-(UILabel *)stockCode
{
    if (_stockCode == nil) {
        UILabel *stockCode = [[UILabel alloc] init];
        [self.contentView addSubview:stockCode];
        stockCode.textColor = NumberColor(178, 176, 179);
        stockCode.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        stockCode.textAlignment = NSTextAlignmentLeft;
        stockCode.text = @"000001";
        [stockCode mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName.mas_right).offset(rate375(4));
            make.centerY.equalTo(self.stockName);
        }];
        _stockCode = stockCode;
    }
    return _stockCode;
}
/****当前状态*****/
-(UIImageView *)currentStatus
{
    if (_currentStatus == nil) {
        UIImageView *currentStatus = [[UIImageView alloc] init];
        [self.contentView addSubview:currentStatus];
        [currentStatus setBackgroundColor:[UIColor clearColor]];
        [currentStatus mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockCode.mas_right).offset(rate375(5));
            make.centerY.equalTo(self.stockName);
        }];
        _currentStatus = currentStatus;
    }
    return _currentStatus;
}
/****时间图示*****/
-(UIImageView *)timeImage
{
    if (_timeImage == nil) {
        UIImageView *timeImage = [[UIImageView alloc] init];
        [self.contentView addSubview:timeImage];
        timeImage.image = [UIImage imageNamed:@"cc-time"];
        timeImage.backgroundColor = [UIColor clearColor];
        timeImage.contentMode = UIViewContentModeScaleAspectFill;
        [timeImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(@(rate375(10)));
            make.left.equalTo(self.stockName);
            if (isPhoneX) {
                make.top.equalTo(self.stockName.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.stockName.mas_bottom).offset(rate750(6));
            }
        }];
        _timeImage = timeImage;
    }
    return _timeImage;
}
/****年月日*****/
-(UILabel *)year
{
    if (_year == nil) {
        UILabel *year = [[UILabel alloc] init];
        [self.contentView addSubview:year];
        year.textColor = NumberColor(178, 176, 179);
        year.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        year.textAlignment = NSTextAlignmentLeft;
        year.text = @"2017.11.09";
        [year mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.timeImage.mas_right).offset(rate375(5));
            make.centerY.equalTo(self.timeImage);
        }];
        _year = year;
    }
    return _year;
}
/****时分秒*****/
-(UILabel *)hour
{
    if (_hour == nil) {
        UILabel *hour = [[UILabel alloc] init];
        [self.contentView addSubview:hour];
        hour.textColor = NumberColor(178, 176, 179);
        hour.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        hour.textAlignment = NSTextAlignmentLeft;
        hour.text = @"11:02:09";
        [hour mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.year.mas_right).offset(rate375(10));
            make.centerY.equalTo(self.timeImage);
        }];
        _hour = hour;
    }
    return _hour;
}


/****订单*****/
-(UILabel *)orderLabel
{
    if (_orderLabel == nil) {
        UILabel *orderLabel = [[UILabel alloc] init];
        [self.contentView addSubview:orderLabel];
        orderLabel.textColor = NumberColor(178, 176, 179);
        orderLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        orderLabel.textAlignment = NSTextAlignmentLeft;
        orderLabel.text = @"交易订单";
        [orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName);
            if (isPhoneX) {
                make.top.equalTo(self.timeImage.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.timeImage.mas_bottom).offset(rate750(6));
            }
        }];
        _orderLabel = orderLabel;
    }
    return _orderLabel;
}

/****订单号*****/
-(UILabel *)orderNumber
{
    if (_orderNumber == nil) {
        UILabel *orderNumber = [[UILabel alloc] init];
        [self.contentView addSubview:orderNumber];
        orderNumber.textColor = NumberColor(178, 176, 179);
        orderNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        orderNumber.textAlignment = NSTextAlignmentLeft;
        orderNumber.text = @"12345678912";
        [orderNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderLabel.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.orderLabel);
        }];
        orderNumber.adjustsFontSizeToFitWidth = YES;
        _orderNumber = orderNumber;
    }
    return _orderNumber;
}
/****点买本金*****/
-(UILabel *)principal
{
    if (_principal == nil) {
        UILabel *principal = [[UILabel alloc] init];
        [self.contentView addSubview:principal];
        principal.textColor = NumberColor(178, 176, 179);
        principal.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        principal.textAlignment = NSTextAlignmentLeft;
        principal.text = @"点买本金";
        [principal mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(10));
            if (isPhoneX) {
                make.top.equalTo(self.orderLabel.mas_bottom).offset(rateX812(20));
            }else{
                make.top.equalTo(self.orderLabel.mas_bottom).offset(rate750(20));
            }
        }];
        _principal = principal;
    }
    return _principal;
}

/****点买数值*****/
-(UILabel *)principalNumber
{
    if (_principalNumber == nil) {
        UILabel *principalNumber = [[UILabel alloc] init];
        [self.contentView addSubview:principalNumber];
        principalNumber.textColor = NumberColor(30, 36, 46);
        principalNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        principalNumber.textAlignment = NSTextAlignmentLeft;
        principalNumber.text = @"0.2万";
        [principalNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.principal.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.principal);
            make.width.equalTo(@(rate375(90)));
        }];
        principalNumber.adjustsFontSizeToFitWidth = YES;
        _principalNumber = principalNumber;
    }
    return _principalNumber;
}

/****可用*****/
-(UILabel *)available
{
    if (_available == nil) {
        UILabel *available = [[UILabel alloc] init];
        [self.contentView addSubview:available];
        available.textColor = NumberColor(178, 176, 179);
        available.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        available.textAlignment = NSTextAlignmentLeft;
        available.text = @"购买数量";
        [available mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(10));
            if (isPhoneX) {
                make.top.equalTo(self.principal.mas_bottom).offset(rateX812(6));
                
            }else{
                make.top.equalTo(self.principal.mas_bottom).offset(rate750(6));
            }
        }];
        _available = available;
    }
    return _available;
}
/****可用数值*****/
-(UILabel *)availableNumber
{
    if (_availableNumber == nil) {
        UILabel *availableNumber = [[UILabel alloc] init];
        [self.contentView addSubview:availableNumber];
        availableNumber.textColor = [UIColor colorWithHexString:Orange];
        availableNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        availableNumber.textAlignment = NSTextAlignmentLeft;
        availableNumber.text = @"100股";
        [availableNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.available.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.available);
            make.width.equalTo(@(rate375(90)));
        }];
        availableNumber.adjustsFontSizeToFitWidth = YES;
        _availableNumber = availableNumber;
    }
    return _availableNumber;
}
/****持仓类型*****/
-(UILabel *)positionType
{
    if (_positionType == nil) {
        UILabel *positionType = [[UILabel alloc] init];
        [self.contentView addSubview:positionType];
        positionType.textColor = NumberColor(178, 176, 179);
        positionType.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        positionType.textAlignment = NSTextAlignmentLeft;
        positionType.text = @"持仓类型";
        [positionType mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(10));
            if (isPhoneX) {
                make.top.equalTo(self.available.mas_bottom).offset(rateX812(6));
                
            }else{
                make.top.equalTo(self.available.mas_bottom).offset(rate750(6));
            }
        }];
        _positionType = positionType;
    }
    return _positionType;
}
-(UILabel *)positionTypeNumber
{
    if (_positionTypeNumber == nil) {
        UILabel *positionTypeNumber = [[UILabel alloc] init];
        [self.contentView addSubview:positionTypeNumber];
        positionTypeNumber.textColor = [UIColor colorWithHexString:Orange];
        positionTypeNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        positionTypeNumber.textAlignment = NSTextAlignmentLeft;
        positionTypeNumber.text = @"--";
        [positionTypeNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.positionType.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.positionType);
            make.width.equalTo(@(rate375(90)));
        }];
        positionTypeNumber.adjustsFontSizeToFitWidth = YES;
        _positionTypeNumber = positionTypeNumber;
    }
    return _positionTypeNumber;
}




/****盈亏*****/
-(UILabel *)profitLoss
{
    if (_profitLoss == nil) {
        UILabel *profitLoss = [[UILabel alloc] init];
        [self.contentView addSubview:profitLoss];
        profitLoss.textColor = NumberColor(178, 176, 179);
        profitLoss.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        profitLoss.textAlignment = NSTextAlignmentLeft;
        profitLoss.text = @"盈亏";
        [profitLoss mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.principalNumber.mas_right);
//            make.left.equalTo(self).offset(rate375(159));
            make.centerY.equalTo(self.principal);
        }];
        _profitLoss = profitLoss;
    }
    return _profitLoss;
}
/****盈亏数值*****/
-(UILabel *)profitLossNumber
{
    if (_profitLossNumber == nil) {
        UILabel *profitLossNumber = [[UILabel alloc] init];
        [self.contentView addSubview:profitLossNumber];
        profitLossNumber.textColor = NumberColor(71, 194, 51);
        profitLossNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        profitLossNumber.textAlignment = NSTextAlignmentLeft;
        profitLossNumber.text = @"-2";
        [profitLossNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.profitLoss.mas_right).offset(rate375(7));
            make.width.equalTo(@(rate375(90)));
            make.centerY.equalTo(self.profitLoss);
        }];
        profitLossNumber.adjustsFontSizeToFitWidth = YES;
        _profitLossNumber = profitLossNumber;
    }
    return _profitLossNumber;
}

/****止损*****/
-(UILabel *)stop
{
    if (_stop == nil) {
        UILabel *stop = [[UILabel alloc] init];
        [self.contentView addSubview:stop];
        stop.textColor = NumberColor(178, 176, 179);
        stop.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        stop.textAlignment = NSTextAlignmentLeft;
        stop.text = @"止损";
        [stop mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(self).offset(rate375(159));
            make.left.equalTo(self.availableNumber.mas_right);
            make.centerY.equalTo(self.available);
        }];
        _stop = stop;
    }
    return _stop;
}
/****止损数值*****/
-(UILabel *)stopNumber
{
    if (_stopNumber == nil) {
        UILabel *stopNumber = [[UILabel alloc] init];
        [self.contentView addSubview:stopNumber];
        stopNumber.textColor = [UIColor colorWithHexString:Orange];
        stopNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        stopNumber.textAlignment = NSTextAlignmentLeft;
        stopNumber.text = @"200元";
        [stopNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stop.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.stop);
            make.width.equalTo(@(rate375(90)));
        }];
        stopNumber.adjustsFontSizeToFitWidth = YES;
        _stopNumber = stopNumber;
    }
    return _stopNumber;
}

/****杠杆*****/
-(UILabel *)gangganLabel
{
    if (_gangganLabel == nil) {
        UILabel *gangganLabel = [[UILabel alloc] init];
        [self.contentView addSubview:gangganLabel];
        gangganLabel.textColor = NumberColor(178, 176, 179);
        gangganLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        gangganLabel.textAlignment = NSTextAlignmentLeft;
        gangganLabel.text = @"杠杆";
        [gangganLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.positionTypeNumber.mas_right);
            make.centerY.equalTo(self.positionTypeNumber);
        }];
        _gangganLabel = gangganLabel;
    }
    return _gangganLabel;
}
-(UILabel *)gangganNumber
{
    if (_gangganNumber == nil) {
        UILabel *gangganNumber = [[UILabel alloc] init];
        [self.contentView addSubview:gangganNumber];
        gangganNumber.textColor = [UIColor colorWithHexString:Orange];
        gangganNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        gangganNumber.textAlignment = NSTextAlignmentLeft;
        gangganNumber.text = @"--";
        [gangganNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.gangganLabel.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.gangganLabel);
            make.width.equalTo(@(rate375(90)));
        }];
        gangganNumber.adjustsFontSizeToFitWidth = YES;
        _gangganNumber = gangganNumber;
    }
    return _gangganNumber;
}


/****买入价*****/
-(UILabel *)bidPrice
{
    if (_bidPrice == nil) {
        UILabel *bidPrice = [[UILabel alloc] init];
        [self.contentView addSubview:bidPrice];
        bidPrice.textColor = NumberColor(178, 176, 179);
        bidPrice.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        bidPrice.textAlignment = NSTextAlignmentLeft;
        bidPrice.text = @"买入价";
        [bidPrice mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(self).offset(rate375(284));
            make.left.equalTo(self.profitLossNumber.mas_right);
            make.centerY.equalTo(self.principal);
        }];
        _bidPrice = bidPrice;
    }
    return _bidPrice;
}
/****买入价数值*****/
-(UILabel *)bidPriceNumber
{
    if (_bidPriceNumber == nil) {
        UILabel *bidPriceNumber = [[UILabel alloc] init];
        [self.contentView addSubview:bidPriceNumber];
        bidPriceNumber.textColor = [UIColor colorWithHexString:Orange];
        bidPriceNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        bidPriceNumber.textAlignment = NSTextAlignmentLeft;
        bidPriceNumber.text = @"11.58";
        [bidPriceNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bidPrice.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.bidPrice);
            make.width.equalTo(@(rate375(42)));
        }];
        bidPriceNumber.adjustsFontSizeToFitWidth = YES;
        _bidPriceNumber = bidPriceNumber;
    }
    return _bidPriceNumber;
}

/****当前价*****/
-(UILabel *)currentPrice
{
    if (_currentPrice == nil) {
        UILabel *currentPrice = [[UILabel alloc] init];
        [self.contentView addSubview:currentPrice];
        currentPrice.textColor = NumberColor(178, 176, 179);
        currentPrice.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        currentPrice.textAlignment = NSTextAlignmentLeft;
        currentPrice.text = @"当前价";
        [currentPrice mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(self).offset(rate375(284));
            make.left.equalTo(self.stopNumber.mas_right);
            make.centerY.equalTo(self.available);
        }];
        _currentPrice = currentPrice;
    }
    return _currentPrice;
}
/****当前价数值*****/
-(UILabel *)currentPriceNumber
{
    if (_currentPriceNumber == nil) {
        UILabel *currentPriceNumber = [[UILabel alloc] init];
        [self.contentView addSubview:currentPriceNumber];
        currentPriceNumber.textColor = [UIColor colorWithHexString:Orange];
        currentPriceNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        currentPriceNumber.textAlignment = NSTextAlignmentLeft;
        currentPriceNumber.text = @"11.58";
        [currentPriceNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.currentPrice.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.currentPrice);
            make.width.equalTo(@(rate375(42)));
        }];
        currentPriceNumber.adjustsFontSizeToFitWidth = YES;
        _currentPriceNumber = currentPriceNumber;
    }
    return _currentPriceNumber;
}

/****是否递延*****/
-(UILabel *)derLabel
{
    if (_derLabel == nil) {
        UILabel *derLabel = [[UILabel alloc] init];
        [self.contentView addSubview:derLabel];
        derLabel.textColor = NumberColor(178, 176, 179);
        derLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        derLabel.textAlignment = NSTextAlignmentLeft;
        derLabel.text = @"是否递延";
        [derLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.gangganNumber.mas_right);
            make.centerY.equalTo(self.gangganNumber);
        }];
        _derLabel = derLabel;
    }
    return _derLabel;
}
-(UILabel *)derLabelNumber
{
    if (_derLabelNumber == nil) {
        UILabel *derLabelNumber = [[UILabel alloc] init];
        [self.contentView addSubview:derLabelNumber];
        derLabelNumber.textColor = [UIColor colorWithHexString:Orange];
        derLabelNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        derLabelNumber.textAlignment = NSTextAlignmentLeft;
        derLabelNumber.text = @"是";
        [derLabelNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.derLabel.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.derLabel);
            make.width.equalTo(@(rate375(42)));
        }];
        derLabelNumber.adjustsFontSizeToFitWidth = YES;
        _derLabelNumber = derLabelNumber;
    }
    return _derLabelNumber;
}
/****卖出按钮*****/
-(SYNoHeightedButton *)saleButton
{
    if (_saleButton == nil) {
        SYNoHeightedButton *saleButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:saleButton];
        [saleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [saleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        [saleButton setTitle:@"卖出" forState:UIControlStateNormal];
        [saleButton setTitle:@"卖出" forState:UIControlStateDisabled];
        [saleButton setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:Orange]] forState:UIControlStateNormal];
        [saleButton setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:Orange alpha:0.3]] forState:UIControlStateDisabled];
        saleButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        saleButton.titleLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        [saleButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(rate375(125)));
            make.right.equalTo(self).offset(-rate375(15));
            make.bottom.equalTo(self.timeImage.mas_bottom);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(30)));
            }else{
                make.height.equalTo(@(rate750(30)));
            }
        }];
        
        saleButton.layer.cornerRadius = 3.0;
        saleButton.layer.masksToBounds = YES;
        
        [saleButton addTarget:self action:@selector(saleButtonClick) forControlEvents:UIControlEventTouchDown];
        
        _saleButton = saleButton;
    }
    return _saleButton;
}

-(void)saleButtonClick
{
    //点击之前先判断当前状态情况
    if ([self.delegate respondsToSelector:@selector(inPositonCellSaleButonCLick:)]) {
        [self.delegate inPositonCellSaleButonCLick:self];
    }
}

-(void)setFrame:(CGRect)frame
{
    CGFloat margin;
    if (isPhoneX) {
        margin = rateX812(5);
    }else{
        margin = rate750(5);
    }
    frame.size.height -= margin * 2;
    frame.origin.y -= margin;
    [super setFrame:frame];
}

-(void)addDashLine
{
    CGFloat y = isPhoneX ? rateX812(84) : rate750(84);
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.lineWidth = 1.0f;
    layer.strokeColor = [UIColor lightGrayColor].CGColor;
    [layer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:2],nil]];
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(rate375(10),y)];
    [path addLineToPoint:CGPointMake(LKScreenW - rate375(10),y)];
    layer.path = path.CGPath;
    [self.layer addSublayer:layer];
}

@end
